home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
amiga
/
gui
/
prcgntn1.lha
/
Precognition
/
source
/
HSlider.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-23
|
4KB
|
182 lines
/* ==========================================================================
**
** HSlider.c
** ⌐1991 WILLISoft
**
** ==========================================================================
*/
#include "minmax.h"
#include "HSlider.h"
#include "HSliderClass.h"
#include <proto/exec.h>
#include <proto/intuition.h>
#include "amigamem.h"
tPoint HSlider_AskSize( HSlider *self,
PIXELS Width,
PIXELS Height )
{
tPoint size;
size.x = MAX( Width, 20 );
size.y = MAX( Height, 10 );
return size;
}
LONG HSlider_Value( HSlider *self )
{
return self->Prop.HorizPot;
}
USHORT HSlider_KnobSize( HSlider *self )
{
return self->Prop.HorizBody;
}
LONG HSlider_SetValue( HSlider *self, LONG value )
{
struct pcgWindow *window;
struct PropInfo propinfo;
USHORT position;
position = value;
propinfo = self->Prop;
if ((window = InteractorWindow( self )) &&
(window->Window))
{
NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
position, propinfo.VertPot,
propinfo.HorizBody, propinfo.VertBody,
1 );
}
else
{
self->Prop.HorizPot = position;
}
return position;
}
USHORT HSlider_SetKnobSize( HSlider *self, USHORT knobsize )
{
struct pcgWindow *window;
struct PropInfo propinfo;
propinfo = self->Prop;
if ((window = InteractorWindow( self )) &&
(window->Window))
{
NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
propinfo.HorizPot, propinfo.VertPot,
knobsize, propinfo.VertBody,
1 );
}
else
{
self->Prop.HorizBody = knobsize;
}
return knobsize;
}
#ifdef BUILDER
#include "BuilderMethods.h"
#include "GraphicObject_Builder.h"
#include "Positioner_Builder.h"
#include "Positioner_Coder.h"
Slider *HSlider_New( HSlider *self )
{
Slider *new_HSlider = NULL;
Point loc, size;
if (new_HSlider = (HSlider *) Amalloc(sizeof(HSlider)))
{
loc = Location(self);
size = Size(self);
HSlider_Init( new_HSlider, loc.x, loc.y, size.x, size.y,
self->eg.Pens, Title(self) );
GiveItAName( new_HSlider );
}
return new_HSlider;
}
struct BuilderMethods HSlider_bm;
#endif
BOOL HSlider_elaborated = FALSE;
struct PositionerClass HSlider_Class;
void HSliderClass_Init( struct PositionerClass *class )
{
SliderClass_Init( class );
class->isa = SliderClass();
class->ClassName = "HSlider";
class->AskSize = HSlider_AskSize;
class->SetValue = HSlider_SetValue;
class->Value = HSlider_Value;
class->SetKnobSize = HSlider_SetKnobSize;
class->KnobSize = HSlider_KnobSize;
#ifdef BUILDER
go_InitBuilderMethods( &HSlider_bm );
HSlider_bm.New = HSlider_New;
HSlider_bm.PropEdit = Positioner_PropEdit;
HSlider_bm.WriteCode = Positioner_WriteCode;
class->BuilderMethods = &HSlider_bm;
#endif
}
struct PositionerClass *HSliderClass( void )
{
if (! HSlider_elaborated)
{
HSliderClass_Init( &HSlider_Class );
HSlider_elaborated = TRUE;
}
return &HSlider_Class;
}
void HSlider_Init( HSlider *self,
PIXELS LeftEdge,
PIXELS TopEdge,
PIXELS Width,
PIXELS Height,
pcg_3DPens Pens,
char *label )
{
Point size;
size = HSlider_AskSize( self, Width, Height );
Slider_Init( self, LeftEdge, TopEdge, size.x, size.y, Pens );
self->eg.isa = HSliderClass();
self->Prop.Flags |= FREEHORIZ;
self->Prop.HorizBody = 0x4000;
SetTitle( self, label );
SetTextAlignment( self, tx_OUTSIDE | tx_LEFT | tx_YCENTER,
STD_XPAD, STD_YPAD );
}